import java.util.Scanner;

/**
 * ClassName: PaySystem
 * Package: PACKAGE_NAME
 * Description:
 *
 * @Author 尚硅谷-宋红康
 * @Create 2025/7/16 18:13
 * @Version 1.0
 *
 *
 * 定义接口 Payment，声明方法 pay(double amount)
 *
 *     实现子类 Alipay, WeChatPay, CreditCardPay
 *
 *     编写一个统一的 PaySystem 类，接受任意支付方式并调用 pay()
 *
 *     新增一种支付方式 UnionPay，不修改已有代码即可接入系统
 */
public class Main {

    public static void main(String[] args) {
//        Payment payment = null;
//        int choice = 0;
//        Scanner in = new Scanner(System.in);
//        System.out.println("请选择支付方式：1.支付宝 2.微信 3.信用卡 4.UnionPay");
//        choice = in.nextInt();
//        switch(choice){
//            case 1:
//                payment = new Alipay();
//                break;
//            case 2:
//                payment = new WeChatPay();
//                break;
//            case 3:
//                payment = new CreditCardPay();
//                break;
//            case 4:
//                payment = new UnionPay();
//                break;
//            default:
//                System.exit(0);
//        }
//        payment.pay(3.1415926);
//    }

        PaySystem paySystem = new PaySystem(new Alipay());//按说这个参数应该是可以在xml文件里改的，但是还没学到
        paySystem.pay(3.1415);
    }
}

class PaySystem{
    Payment payment;

    public PaySystem(Payment payment) {
        this.payment = payment;
    }

    void pay(double amount){
        this.payment.pay(amount);
    }
}

class Alipay implements Payment {
    @Override
    public void pay(double amount) {
        System.out.println("支付宝支付：" + amount);
    }
}
class WeChatPay implements Payment {
    @Override
    public void pay(double amount) {
        System.out.println("微信支付：" + amount);
    }
}
class CreditCardPay implements Payment {
    @Override
    public void pay(double amount) {
        System.out.println("信用卡支付：" + amount);
    }
}
class UnionPay implements Payment {
    @Override
    public void pay(double amount) {
        System.out.println("UnionPay支付：" + amount);
    }
}
